package com.xml.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author xml E-Mail:kaioct@qq.com
 * @date 2021/3/24
 * @desc seckilldemo
 * @created 2021-03-24 20:49
 **/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class MyResponseBean {
    private long code;
    private String message;
    private Object object;

    //成功返回结果,一般是200
    public static MyResponseBean success() {
        return new MyResponseBean(MyResponseBeanEnum.SUCCESS.getCode(), MyResponseBeanEnum.SUCCESS.getMessage(), null);
    }

    //成功返回结果,一般是200
    public static MyResponseBean success(Object obj) {
        return new MyResponseBean(MyResponseBeanEnum.SUCCESS.getCode(), MyResponseBeanEnum.SUCCESS.getMessage(), obj);
    }

    //失败返回结果，一般失败各有不同
    public static MyResponseBean error(MyResponseBeanEnum respBeanEnum) {
        return new MyResponseBean(respBeanEnum.getCode(), respBeanEnum.getMessage(), null);
    }

    public static MyResponseBean error(MyResponseBeanEnum respBeanEnum, Object obj) {
        return new MyResponseBean(respBeanEnum.getCode(), respBeanEnum.getMessage(), obj);
    }
}
